namespace Microsoft.ServiceModel.Samples.Discovery.Protocol
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.ServiceModel;

    
    [XmlType(Namespace = ProtocolStrings.Namespace)]
    [XmlRoot(ProtocolStrings.HelloElement,
        Namespace = ProtocolStrings.Namespace)]
    public class Hello : ServiceProperties
    {
        public static Hello FromServiceProperties(
            ServiceProperties serviceProperties)
        {
            if (serviceProperties == null)
                throw new ArgumentNullException("serviceProperties");

            Hello hello = new Hello();

            hello.EndpointAddress = serviceProperties.EndpointAddress;
            hello.MetadataVersion = serviceProperties.MetadataVersion;
            hello.Types = serviceProperties.Types;
            hello.Scopes = serviceProperties.Scopes;
            hello.XAddrs = serviceProperties.XAddrs;
            hello.AnyElements = serviceProperties.AnyElements;
            hello.AnyAttributes = serviceProperties.AnyAttributes;

            return hello;
        }

        public bool IsValid()
        {
            return (this.EndpointAddress != null);
        }
    }
}
